/*
 * GeoVISTA Center (Penn State, Dept. of Geography)
 * Copyright (c), 2003-2011,  Jin Chen and Alan M. MacEachren, GeoVISTA Center, Penn State University
 * All Rights Researved.
 *
 * This library is developed and distributed for free usage,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * You can redistribute and/or modify it under the terms of the
 * Simplified BSD License
 *
 *
 *
 *
 *
 *
 *
 *  
 * @Original Author: jin Chen
 * @date: Apr 15, 2004$
 * @version: 1.0
 */
package edu.psu.geovista.app.dataloader.v1.gui;

import edu.psu.geovista.app.dataloader.v1.DataLoaders;
import epoviz.trex.common.swing.layout.UnevenRowSectionPane;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;

public class AttributesPane extends BasicPane{

    public AttributesPane(DataLoaders dataloader) {
       super(dataloader);
        this.showPcpTs();


        deselectAllAttributes();
    }
    //for manually load data, users prefer not select pre-configured data, so deselect all.
    public void deselectAllAttributes() {
        this.pcpload.deSelectAllAttributes();
        this.tsload.deSelectAllAttributes();


    }

    /*public void setButtonAction(int bttn,Action a) {
           if(bttn==DataLoaders.Btn_OK){
             this.okBtn.setAction(a);
             okBtn.setText("Finish");
        }
        /*else if(bttn==DataLoaders.Btn_Next){
             nextBtn.setAction(a);
             nextBtn.setText("Next>");
        }
        else if(bttn==DataLoaders.Btn_Back){
              this.backBtn.setAction(a);
            this.backBtn.setText("<Back");
        }
        }*/
    public void showPcpOnly(){
        this.removeAll();
         this.setLayout(new BorderLayout());
        this.add(this.getPcpPane() );
        this.add(this.getControlPane(),BorderLayout.SOUTH );
        this.revalidate() ;
    }
    public void showTsOnly() {
        this.removeAll();
         this.setLayout(new BorderLayout());
        this.add(this.getTsPane() );
        this.add(this.getControlPane(),BorderLayout.SOUTH );
        this.revalidate() ;
    }
    public void showPcpTs() {
        this.removeAll();
         this.setLayout(new BorderLayout());
         //main pane
         JPanel pcppath=this.getPcpPane() ;
         JPanel tspath=this.getTsPane() ;

         UnevenRowSectionPane p=new UnevenRowSectionPane();
         p.clearMainPane();
         p.removeControlPane();

         JComponent[] comps=new JComponent[]{pcppath,tspath};
         double[] ws=new double[]{2,2};
         p.addToMainPane(comps,ws);

         //put them together
         this.add(p);
         this.add(this.getControlPane(),BorderLayout.SOUTH  ) ;
          this.revalidate() ;
    }

    protected  JPanel getPcpPane(){
        JPanel p=this.pcpload.getDataList();
         TitledBorder border = new TitledBorder("Primary data ");
         border.setTitleColor(DataLoaders.COLOR_SECTION_TITLE );
         border.setTitleFont(DataLoaders.FONT_SECTION_TITLE );
         p.setBorder(border);
         return p;
    }
    protected JPanel getTsPane(){
         JPanel p=this.tsload.getDataList();
         TitledBorder border = new TitledBorder("Time Series data ");
         border.setTitleColor(DataLoaders.COLOR_SECTION_TITLE );     //Color.BLUE
         border.setTitleFont(DataLoaders.FONT_SECTION_TITLE );
         p.setBorder(border);
         return p;
    }
    protected void setControlPane(JPanel p){
        p.add(leftBtn);
        //p.add(midBtn);
        p.add(rightBtn);

    }

    /*private void set() {
        JPanel pcpAttrs=this.pcpload.getDataList();
        JPanel tsAttrs=this.tsload.getDataList() ;

        JButton setPathBtn=new JButton();
        BasicAction act = this.getAction(ActionManager.Act_SetPath);
        setPathBtn.setAction(act);
        setPathBtn.setText("Set data paths") ;
        //setPathBtn.setAction(new SetPathAction("Set paths",this));

        JButton okBtn=new JButton();
        BasicAction flact = this.getAction(ActionManager.Act_FinalLoad);
        okBtn.setAction(flact);
        okBtn.setText("OK");
        // okBtn.setAction(new FinalLoadAction("OK",this));

        EvenRowSectionsPane p=new EvenRowSectionsPane(2,1);
        p.clearControlPane() ;
        p.clearMainPane();

        p.addToMainPane(pcpAttrs);
        p.addToMainPane(tsAttrs);
        p.addToControlPane(setPathBtn);
        p.addToControlPane(okBtn);

        this.showPaneInDlg(p,new Dimension(Dlg_W,Dlg_H),"Select attributes");
    }*/
}
